package com.fowo.api.sys.controller;

import com.fowo.api.common.model.R;
import com.fowo.api.sys.annotation.RedisSyncLock;
import com.fowo.api.sys.model.NewSerialRequest;
import com.fowo.api.sys.service.SysSerialService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Tag(name = "系统序列号")
@RequestMapping("/api/sys/serial")
@RestController
public class SysSerialController {

    @Resource
    private SysSerialService sysSerialService;

    @Operation(summary = "请求一个新序列号")
    @PostMapping("new")
    @RedisSyncLock(value = "serial_new", timeout = 30)
    public R<String> getNewSerial(@RequestBody NewSerialRequest request) {
        return R.data(sysSerialService.getNewSerial(request));
    }
}
